﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace HRWEB.HtmlHelpers
{
    public class DropDownListHelper
    {
        public static SelectList TheisMagazineIndexList()
        {
            hrdbEntities ent = new hrdbEntities();
            return new SelectList(ent.DictThesisMagazineIndexes.AsNoTracking(), "MagazineIndexCode", "FName");
        }
        public static SelectList ThesisAuthorOrderList()
        {
            hrdbEntities ent = new hrdbEntities();
            return new SelectList(ent.DictThesisAuthorOrders.AsNoTracking(), "OrderCode", "FName");
        }
        public static SelectList ThesisTypeList()
        {
            hrdbEntities ent = new hrdbEntities();
            return new SelectList(ent.DictThesisTypes.AsNoTracking(), "TypeCode", "FName");
        }
        public static SelectList MagazineGradeList()
        {
            hrdbEntities ent = new hrdbEntities();
            return new SelectList(ent.DictMagazineGrades.AsNoTracking(), "FGradeCode", "FName");
        }
        public static SelectList MagazineTypeList()
        {
            hrdbEntities ent = new hrdbEntities();
            return new SelectList(ent.DictMagazineTypes.AsNoTracking(), "FTypeCode", "FName");
        }
        public static SelectList JobTypeListItem()
        {
            hrdbEntities ent = new hrdbEntities();
            return new SelectList(ent.TDictJobTypes.AsNoTracking().Where(p => p.FJobTypeCode.Length == 6), "FJobTypeCode", "FName");
        }
        public static SelectList JobLevelListItem()
        {
            hrdbEntities ent = new hrdbEntities();
            return new SelectList(ent.TDictJobLevels.AsNoTracking().Where(p => p.FJobLevelCode.Length == 4 && p.FJobLevelCode.CompareTo("0601") < 0),"FJobLevelCode","FName");
        }
        public static SelectList DeptListItem(string inputCode,string selected)
        {
            hrdbEntities ent = new hrdbEntities();
            return new SelectList(ent.TDictDepts.Where(p => p.FInputCode.Contains(inputCode)).OrderBy(p => p.FName), "FDeptCode", "FName",selected);
        }
        public static SelectList GetRelationList(string selected)
        {
            hrdbEntities ent = new hrdbEntities();
            return new SelectList(ent.TDictRelations, "FRelationCode", "FName", selected);
        }
        public static SelectList GetGenderList(string selected)
        {
            hrdbEntities ent = new hrdbEntities();
            return new SelectList(ent.TDictGenders, "FGenderCode", "FName", selected);

        }
        public static SelectList GetPartyList(string selected)
        {
            hrdbEntities ent = new hrdbEntities();
            return new SelectList(ent.TDictParties, "FPartyCode", "FName", selected);

        }
    }
}